var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIConfig"),
    s = t("UIManager"),
    c = t("GameBaseManager"),
    p = t("AdView"),
    l = cc._decorator,
    d = l.ccclass,
    u = l.property,
    h =
        (l.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.lab = null;
                e.conRecord = null;
                e.conShare = null;
                e.sharePro = null;
                e.isUpdataViewBtnTime = !1;
                e.shareTime = 0;
                e.delayTime = 30;
                return e;
            }
            e.prototype.onLoad = function () {
                this._addClickListener();
                this.checkViewBtn();
                RecordVideoManager.addUpdataCallBack(this.checkViewBtn.bind(this));
                this.schedule(this.autoRecord, 180, 1e3, 30);
            };
            e.prototype.onEnable = function () {
                "tt" != p.default.curPlat ? (this.node.active = !1) : (this.node.active = !0);
            };
            e.prototype.autoRecord = function () {
                if ("tt" == p.default.curPlat) {
                    c.default.isRecordEnd = !1;
                    console.log("延迟时间为", this.delayTime, RecordVideoManager.curRecordTime);
                    RecordVideoManager.clear();
                    RecordVideoManager.setStopSuccessCallBack(function () {
                        console.log("弹出分享界面");
                        s.default.open(r.UIID.UIRecordShare);
                    });
                    RecordVideoManager.start(
                        function () {
                            console.log("开始录屏111111111111111");
                        },
                        function () {
                            console.log("开始录屏222222");
                        }
                    );
                }
            };
            e.prototype.checkViewBtn = function () {
                this.lab.string = RecordVideoManager.getBtnStr();
                this.isUpdataViewBtnTime = RecordVideoManager.isRecord();
                this.conShare.active = !1;
                this.conRecord.active = !0;
                this.conShare.active = RecordVideoManager.canShareVideo();
                this.conRecord.active = !this.conShare.active;
            };
            e.prototype.updataBtnStr = function () {
                this.isUpdataViewBtnTime && (this.lab.string = RecordVideoManager.getBtnStr());
                RecordVideoManager.isGetReward && this.conShare.active && this.checkViewBtn();
            };
            e.prototype.update = function () {
                this.updataBtnStr();
            };
            e.prototype.onDestroy = function () {
                this._removeClickListener();
                RecordVideoManager.stop(
                    function () {
                        RecordVideoManager.clear();
                    },
                    function () {
                        RecordVideoManager.clear();
                    }
                );
                RecordVideoManager.clear();
                RecordVideoManager.clearUpdataCallBack();
            };
            e.prototype._touchStart = function () {};
            e.prototype._touchCancel = function () {
                var t = this;
                if (RecordVideoManager.canStartRecord())
                    RecordVideoManager.start(
                        function () {
                            t.checkViewBtn();
                        },
                        function () {
                            t.checkViewBtn();
                        }
                    );
                else {
                    if (RecordVideoManager.canShareVideo()) {
                        console.log("弹出分享界面");
                        s.default.open(r.UIID.UIRecordShare);
                        return !0;
                    }
                    RecordVideoManager.stop(
                        function () {
                            c.default.getShareRewardTimes() < 3 &&
                                setTimeout(function () {
                                    s.default.open(r.UIID.UIRecordShare);
                                }, 1e3);
                            t.checkViewBtn();
                        },
                        function () {
                            t.checkViewBtn();
                            s.default.open(r.UIID.UIToast, {msg: "时长不能小于3秒"});
                        }
                    );
                }
                this.checkViewBtn();
            };
            e.prototype._touchMove = function () {};
            e.prototype._addClickListener = function () {
                this.node.on(cc.Node.EventType.TOUCH_START, this._touchStart, this);
                this.node.on(cc.Node.EventType.TOUCH_END, this._touchCancel, this);
                this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._touchCancel, this);
                this.node.on(cc.Node.EventType.TOUCH_MOVE, this._touchMove, this);
            };
            e.prototype._removeClickListener = function () {
                this.node.off(cc.Node.EventType.TOUCH_START, this._touchStart, this);
                this.node.off(cc.Node.EventType.TOUCH_END, this._touchCancel, this);
                this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._touchCancel, this);
                this.node.off(cc.Node.EventType.TOUCH_MOVE, this._touchMove, this);
            };
            n([u(cc.Label)], e.prototype, "lab", void 0);
            n([u(cc.Node)], e.prototype, "conRecord", void 0);
            n([u(cc.Node)], e.prototype, "conShare", void 0);
            n([u(cc.Sprite)], e.prototype, "sharePro", void 0);
            return n([d], e);
        })(cc.Component));
o.default = h;
